<template>
  <el-container>
    <el-header style="border-bottom: 1px solid rgba(255,255,255,0.12)">
      <p style="font-family: MicrosoftYaHei;font-size: 16px;color: #7DDAFF;">上报情况详情</p>
    </el-header>
    <el-main>
      <el-row class="btn-group">
        <el-button class="btn" @click="handleDownloadDataRe">
          <span>导出</span><i class="el-icon-download"></i>
        </el-button>
      </el-row>

      <el-table :data="dataList"
                v-loading="listLoading"
                :row-class-name="tableRowClassName"
                element-loading-text="给我一点时间"
                height="500"
                element-loading-background="rgba(0, 0, 0, .3)"
                style="width: 100%;padding-top: 0px;background-color: #1B4685" ref="dataReTable">
        <el-table-column fixed sortable align="center" label="车场名称" prop="parkName">
          <template slot-scope="scope">
            <span>{{scope.row.parkName}}</span>
          </template>
        </el-table-column>
        <el-table-column align="center" label="经营单位" sortable prop="name">
          <template slot-scope="scope">
            <span>{{scope.row.name}}</span>
          </template>
        </el-table-column>
        <el-table-column align="center" label="入场数" sortable prop="uploadNumForIn" width="120">
          <template slot-scope="scope">
            <span>{{scope.row.uploadNumForIn}}</span>
          </template>
        </el-table-column>
        <el-table-column align="center" label="出场数" sortable prop="uploadNumForOut" width="120">
          <template slot-scope="scope">
            <span>{{scope.row.uploadNumForOut}}</span>
          </template>
        </el-table-column>
        <el-table-column align="center" label="上传剩余泊位次数" sortable prop="uploadNumForRemain" width="120">
          <template slot-scope="scope">
            <span>{{scope.row.uploadNumForRemain}}</span>
          </template>
        </el-table-column>
        <el-table-column align="center" label="总泊位数" sortable prop="totalPlace" width="120">
          <template slot-scope="scope">
            <span>{{scope.row.totalPlace}}</span>
          </template>
        </el-table-column>
        <el-table-column align="center" label="异常情况" width="150" show-overflow-tooltip prop="abnormalType">
          <template slot-scope="scope">
            <span>
              <el-button size="mini" @click="openError(scope.row.msgList)">查看异常</el-button>
              <!--<el-tag v-if="scope.row.abnormalType === 6" type="danger">上报剩余泊位次数过少</el-tag>-->
            </span>
          </template>
        </el-table-column>
        <el-table-column fixed="right" align="center" label="统计日期" show-overflow-tooltip sortable prop="date">
          <template slot-scope="scope">
            <span>{{scope.row.date}}</span>
          </template>
        </el-table-column>


        <!--<el-table-column fixed="right" align="center"  label="操作">-->
        <!--<template slot-scope="scope">-->
        <!--<el-dropdown trigger="click" @command="handleCommand">-->
        <!--<el-button class="btn-drop-down" @click="selectRow(scope.row)">-->
        <!--<i class="el-icon-arrow-down"></i>-->
        <!--</el-button>-->
        <!--<el-dropdown-menu slot="dropdown">-->
        <!--<el-dropdown-item command="edit">编辑</el-dropdown-item>-->
        <!--<el-dropdown-item command="del">删除</el-dropdown-item>-->
        <!--</el-dropdown-menu>-->
        <!--</el-dropdown>-->
        <!--</template>-->
        <!--</el-table-column>-->
      </el-table>

    </el-main>
    <el-footer>
      <el-pagination style="margin-top: 16px" background
                     @size-change="handleSizeChangeDataRe"
                     @current-change="handleCurrentChangeDataRe"
                     :current-page="listQuery.page"
                     :page-sizes="[10,20,30, 50]"
                     :page-size="listQuery.limit"
                     layout="total, sizes, prev, pager, next, jumper" :total="total">
      </el-pagination>
    </el-footer>
    <el-dialog title="异常信息" :visible.sync="errorVisible" center width="520px">
      <el-container>
        <el-main>
          <el-row v-for="item in errorMsg" style="text-align: center">
            <el-tag type="danger"><i class="el-icon-warning"></i>{{item}}</el-tag>
          </el-row>
        </el-main>
      </el-container>
    </el-dialog>
  </el-container>
</template>

<script>
  /* eslint-disable */
  export default {
    name: "data-re-table",
    props: ['searchList', 'listLoadingDataRe'],
    watch: {
      searchList(val) {
        this.dataList = val.list
        this.total = val.count
      },
      listLoadingDataRe(val) {
        this.listLoading = val
      }
    },
    data() {
      return {
        listLoading: false,
        errorVisible: false,
        dialogDwVisibleDataRe: false,
        dataList: [],
        total: 0,
        errorMsg: [],
        listQuery: {
          page: 1,
          limit: 20
        },
        tempDataRe: {}
      }
    },
    methods: {
      handleDownloadDataRe() {
      },
      handleSizeChangeDataRe(val) {
        this.listQuery.limit = val
        this.$emit("handleSizeChangeDataRe", val)
      },
      openError(val) {
        console.log(val)
        this.errorMsg = val;
        this.errorVisible = true;
      },
      handleCurrentChangeDataRe(val) {
        this.listQuery.page = val
        this.$emit("handleCurrentChangeDataRe", val)
      },
      tableRowClassName(row, rowIndex) {
        if (rowIndex % 2 === 0) {
          return "one-row"
        }
        return ''
      },
      closeModals() {
        this.errorVisible = false;
      },
      tableRowClassName({ row, rowIndex }) {
        if (rowIndex % 2 === 0) {
          return 'one-row';
        } else {
          return '';
        }
      }
    }
  }
</script>

<style scoped>
  .el-table .warning-row {
    background: #3b6cff;
  }

  .btn-group > .el-button span {
    display: none;
  }

  .btn-group > .el-button:hover {
    background-color: #409EFF;
  }

  .btn-group > .el-button:hover span {
    display: block;
  }

  .btn-group > .el-button:hover i {
    display: none;
  }

</style>
